[求助]matlab拟合数据

来源:百度知道 编辑:UC知道 时间:2024/06/01 16:32:35
高手帮下忙~
哪位能帮我把这组数据拟合一下,急用,但是重来没有接触过matlab不会弄。。。
年份 口语总分平均成绩
1992 30
1993 31
1994 32
1995 34
1996 42
1997 48
1998 55
1999 58
2000 62
2001 63
2002 65
2003 65
2004 66
这个在04年以后增长很慢,逼近一个极值

用s函数的变型。

A=[...
1992 30
1993 31
1994 32
1995 34
1996 42
1997 48
1998 55
1999 58
2000 62
2001 63
2002 65
2003 65
2004 66];
x=A(:,1);y=A(:,2);
fun=inline('a(1)*tanh(a(2)*(x-a(3)))+a(4)','a','x')
format short g
x0=[20 0.001 1985 10];
%x0=[18.352 0.37782 1996.9 47.028];
a=nlinfit(x,y,fun,x0)
x1=min(x):0.1:max(x)+5;
y1=fun(a,x1);
plot(x,y,'o',x1,y1)
[A,fun(a,x)]

结果:

a =

18.352 0.37782 1996.9 47.028

ans =

1992 30 29.558
1993 31 30.504
1994 32 32.36
1995 34 35.72
1996 42 41.002
1997 48 47.703
1998 55 54.229
1999